package taller2.controller.listeners.SupervisorMenus;

import javax.swing.JComboBox;

import taller2.controller.listeners.MouseHandler;
import taller2.controller.listeners.GraphCreator.GraphCreatorMenuListener;
import taller2.controller.modes.SelectConnectionsMode;
import taller2.controller.modes.UnSelectConnectionsMode;
import taller2.interfaces.AlgorithmApplicator;
import taller2.interfaces.Graph;
import taller2.utils.Constants;
import taller2.view.draws.DrawingArea;

public class ConnectedComponentSupervisorMenuListener extends GraphCreatorMenuListener{
	
	public ConnectedComponentSupervisorMenuListener(DrawingArea area, Graph graph,
			AlgorithmApplicator algorithmApplicator) {
		super(area, graph, algorithmApplicator);
		
		this.setAvailableOptions(Constants.ConnectedComponentSupervisorOptions);
	}

	// handles the event if it is a menu change
	@Override
	protected void handleMenu(MouseHandler handler,JComboBox<?> menu){
        String selected = (String) menu.getSelectedItem();
    
		if(selected.equals(getAvailableOptions()[0])){
			handler.ChangeMode(new SelectConnectionsMode(graph));
		}else{
			if(selected.equals(getAvailableOptions()[1]))
				handler.ChangeMode(new UnSelectConnectionsMode(graph));
		}
	}
	
}